package gsw.demo.pluggable2.plugin_simple;

import android.app.Activity;
import android.content.res.AssetManager;
import android.content.res.Resources;

public class ActivityBase extends Activity {

    /**
     * 在宿主中获取插件资源
     *
     * @return 融合了插件和宿主的资源
     */
    @Override
    public Resources getResources() {
        //如果是宿主环境，getApplication返回宿主的Application
        if (getApplication() != null && getApplication().getResources() != null) {
            return getApplication().getResources();
        }
        return super.getResources();
    }

    /**
     * 在宿主中获取插件资产
     *
     * @return 融合了插件和宿主的资产
     */
    @Override
    public AssetManager getAssets() {
        if (getApplication() != null && getApplication().getAssets() != null) {
            return getApplication().getAssets();
        }
        return super.getAssets();
    }
}
